package com.burgeon.backend.SHOPBACKEND.controller;

import com.burgeon.backend.SHOPBACKEND.entity.Banner;
import com.burgeon.backend.SHOPBACKEND.entity.IndexImg;
import com.burgeon.backend.SHOPBACKEND.entity.Seckill;
import com.burgeon.backend.SHOPBACKEND.service.BackentIndexImgService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("backend/index")
public class BackentIndexImgController extends BaseController {
    /**
     * 首页图
     */
    @Autowired
   private BackentIndexImgService backentImgService;

    /**
     * 上传首页轮播图
     * @param file
     * @param account
     * @return
     */
    @RequestMapping("banner")
    public ResponseResult<Void> addIndexBanner(MultipartFile file, String account,String type,String message){

        backentImgService.addIndexBanner(file,account,type, message);
        return new ResponseResult<>(SUCCESS);
    }

    /**
     * 删除首页轮播图根据轮播id
     * @param id
     * @return
     */
    @RequestMapping("deBanner")
    public ResponseResult<Void> deIndexBanner(String id){

        backentImgService.deIndexBannerById(id);
        return new ResponseResult<>(SUCCESS);
    }

    /**
     * 查看首页轮播图
     * @param account
     * @return
     */
    @RequestMapping("findBanner")
    public ResponseResult<List<Banner>> findIndexBanner(String account){
        List<Banner> data = backentImgService.findIndexBanner(account);

        return new ResponseResult<List<Banner>>(SUCCESS,data);
    }

    /**
     * 查看首页新品上市
     * @param account
     * @return
     */
    @RequestMapping("findNew")
    public ResponseResult<IndexImg> findIndexNew(String account){
        IndexImg data = backentImgService.findIndexNew(account);

        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 查看首页活动专区图
     * @param account
     * @return
     */
    @RequestMapping("findActivity")
    public ResponseResult<IndexImg> findIndexActivity(String account){
        IndexImg data = backentImgService.findIndexActivity(account);

        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 查看首页积分商城图
     * @param account
     * @return
     */
    @RequestMapping("findJf")
    public ResponseResult<IndexImg> findIndexJf(String account){
        IndexImg data = backentImgService.findIndexJf(account);

        return new ResponseResult<>(SUCCESS,data);
    }

    /**
     * 上传新品上市图
     * @param file
     * @param account
     * @return
     */
    @RequestMapping("new")
    public ResponseResult<Void> upIndexNew(MultipartFile file, String account){
        backentImgService.upIndexNew(file,account);
        return new ResponseResult<>(SUCCESS);
    }

    /**
     * 上传活动专区图
     * @param file
     * @param account
     * @return
     */
    @RequestMapping("activity")
    public ResponseResult<Void> upIndexActivity(MultipartFile file, String account){
        backentImgService.upIndexActivity(file,account);
        return new ResponseResult<>(SUCCESS);
    }

    /**
     * 上传会员专区图
     * @param file
     * @param account
     * @return
     */
    @RequestMapping("hyzx")
    public ResponseResult<Void> upIndexHyzx(MultipartFile file, String account){
        backentImgService.upHyzx(file,account);
        return new ResponseResult<>(SUCCESS);
    }

    /**
     * 上传积分生活图
     * @param file
     * @param account
     * @return
     */
    @RequestMapping("jfsh")
    public ResponseResult<Void> upIndexJfsh(MultipartFile file, String account){
        backentImgService.upJfsh(file,account);
        return new ResponseResult<>(SUCCESS);
    }

    /**
     * 上传积分换购图
     * @param file
     * @param account
     * @return
     */
    @RequestMapping("jfhg")
    public ResponseResult<Void> upIndexJfhg(MultipartFile file, String account){
        backentImgService.upJfhg(file,account);
        return new ResponseResult<>(SUCCESS);
    }

    /**
     * 上传积分礼券图
     * @param file
     * @param account
     * @return
     */
    @RequestMapping("jflq")
    public ResponseResult<Void> upIndexJflq(MultipartFile file, String account){
        backentImgService.upJflq(file,account);
        return new ResponseResult<>(SUCCESS);
    }

  /*************************************秒杀*******************************************/
    /**
     * 上传秒杀
     * @param file
     * @param account
     * @return
     */
    @RequestMapping("Seckill")
    public ResponseResult<Void> upIndexSeckill(MultipartFile file, String account)  {
        backentImgService.addIndexSkill(file,account);
        return new ResponseResult<>(SUCCESS);
    }


    /**
     * 查看首页秒杀
     * @param account
     * @return
     */
    @RequestMapping("findSeckill")
    public ResponseResult<Seckill> findIndexSeckill(String account){
        Seckill data = backentImgService.findIndexSeckill(account);

        return new ResponseResult<>(SUCCESS,data);
    }



}
